home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-1.iso / games / lorri4.zip / CASTING.SCR < prev    next >
Text File  |  1995-09-24  |  13KB  |  472 lines

  1. !
  2. ! CASTING.SCR - Spell Casting script
  3. !
  4. ! This script implements spell casting for wizards and elves.
  5. !
  6. ! (c) DC Software, 1989-1995
  7. !
  8. ! Pending Enhancements
  9. !
  10. ! - Most of this script is duplicated in the CURRITEM script since
  11. !   these spells can also be invoked from an object (like a staff
  12. !   or a scroll).  However, the script in CURRITEM.SCR looks at the
  13. !   'curritem' to determine what spell needs to be invoked, while 
  14. !   this script just casts the spell based on the magic user's 
  15. !   commands (i.e. no 'curritem' is needed)
  16.  
  17. :@CAST
  18.  
  19. if player.hp = 0 then 
  20.   writeln( player.name, " is dead!" );
  21.   STOP;
  22. endif;
  23.  
  24. if player.class <> WIZARD and player.class <> ELF then
  25.   writeln( player.name, " does not have magical abilities." );
  26.   STOP;
  27. endif;
  28.  
  29. if player.pwr <= 0 then
  30.   writeln( player.name, " has no power left.." );
  31.   STOP;
  32. endif;
  33.  
  34. if fighting then
  35.   L0 = select( "Kill", 20, "Confuse", 1, "Scare", 2, "Damage", 5, "Paralyze", 5 );
  36.   on L0 goto X_KILL, X_CONFUSE, X_SCARE, X_DAMAGE, X_PARALYZE;
  37. else
  38.   L0 = select( "Destroy",       5,
  39.                "Duplicate",    40,
  40.                "Leave",         5,
  41.                "Resurrect",    50,
  42.                "Inform",        5,
  43.                "Locate Doors", 10,
  44.                "Recharge",     25,
  45.                "Float",        10,
  46.                "Analyze",      10,
  47.                "View",         10 );
  48.   on L0 goto X_DESTROY, X_DUPLICATE, X_LEAVE, X_RESURRECT, X_INFORM,
  49.              X_LOCATE, X_RECHARGE,  X_FLOAT, X_ANALYZE,   X_ZOOM;
  50. endif;
  51.  
  52. writeln( "Ok." );
  53. stats(-1); ! Refresh Statistics !
  54. :XSTOP
  55. STOP;
  56.  
  57. :X_DESTROY  
  58.   L0 = DESTROY;   L1 = 5;  L2 = 10;
  59.  
  60.   gosub X_TARGET; goto X_DOIT;
  61.  
  62. :X_DUPLICATE
  63.   L0 = DUPLICATE; L1 = 40; L2 = 1;
  64.   gosub X_TARGET; goto X_DOIT;
  65.  
  66. :X_LEAVE  
  67.   L0 = LEAVE; L1 = 5;
  68.   goto X_DOIT;
  69.  
  70. :X_RESURRECT
  71.   L0 = RESURRECT; L1 = 50;
  72.   goto X_DOIT;
  73.  
  74. :X_INFORM  
  75.   L0 = INFORM; L1 = 5;
  76.   goto X_DOIT;
  77.  
  78. :X_LOCATE 
  79.   L0 = DOORS; L1 = 10;
  80.   goto X_DOIT;
  81.  
  82. :X_KILL  
  83.   L0 = KILL;    L1 = 20; L2 = 6;
  84.   gosub X_TARGET; goto X_DOIT;
  85.  
  86. :X_CONFUSE  
  87.   L0 = CONFUSE; L1 =  1;
  88.   goto X_DOIT;
  89.  
  90. :X_SCARE  
  91.   L0 = SCARE;   L1 =  2;
  92.   goto X_DOIT;
  93.  
  94. :X_DAMAGE  
  95.   L0 = DAMAGE;  L1 =  5;
  96.   goto X_DOIT;
  97.  
  98. :X_PARALYZE
  99.   L0 = PARALYZE; L1 = 5;
  100.   goto X_DOIT;
  101.  
  102. :X_RECHARGE
  103.   L0 = RECHARGE; L1 = 25; L2 = 1;
  104.   gosub X_TARGET; goto X_DOIT;
  105.  
  106. :X_FLOAT  
  107.   L0 = FLOAT; L1 = 10; L2 = 1;
  108.   gosub X_TARGET; goto X_DOIT;
  109.  
  110. :X_ANALYZE  
  111.   L0 = ANALYZE; L1 = 10; L2 = 1; 
  112.   gosub X_TARGET; goto X_DOIT;
  113.  
  114. :X_ZOOM  
  115.   L0 = ZOOM; L1= 10;
  116.   goto X_DOIT;
  117.  
  118. :X_DOIT
  119.   if player.pwr < L1 then
  120.     writeln( player.name, " doesn't have enough power.." );
  121.     goto XSTOP;
  122.   endif;
  123.  
  124.   dec( player.pwr, L1 );
  125.  
  126.   if L0 = DAMAGE or L0 = CONFUSE or L0 = SCARE or L0 = PARALYZE then
  127.     !
  128.     ! These spells operate on EVERY monster
  129.     !
  130.     ! L5 will contain the TOTAL experience points gained when done..
  131.     ! L6 is the maximum damage that will be done to a single monster..
  132.     ! L8 is the maximum total damage that can be done to a group of monsters..
  133.     ! L9 is the number of monsters affected..
  134.     !
  135.     L5 = 0;
  136.     L6 = player.level + adjustments(player.pwr) / 2 + 1;
  137.     if L6 <= 0 then
  138.       voice( "BOING", 1000 );
  139.       writeln( "The spell failed.." );
  140.       goto XSTOP;
  141.     endif;
  142.     L8 = player.iq;
  143.     L9 = 0;
  144.   endif;
  145.  
  146.   on L0 goto 
  147.     M2_NONE,     M2_DESTROY,  M2_DUPLICATE, M2_LEAVE,
  148.     M2_RESURRECT,M2_INFORM,   M2_LOCATE,    M2_KILL, 
  149.     M2_CONFUSE,  M2_SCARE,    M2_DAMAGE,    M2_PARALYZE,
  150.     M2_RECHARGE, M2_FLOAT,    M2_ANALYZE,   M2_ZOOM;
  151.  
  152. :M2_NONE      ! No spell
  153.   writeln( "Nothing happens.." );
  154.   goto XSTOP;
  155.  
  156. :M2_DESTROY   ! Destroy an object
  157.   voice( "EXPLODE", 1000 );
  158.   writeln( "The ", object.type, " is destroyed.." );
  159.   vanish( object );
  160.   goto XSTOP;
  161.  
  162. :M2_DUPLICATE ! Duplicates an object
  163.   voice( "TADA", 1000 );
  164.   writeln( "The ", object.type, " has been duplicated.. " );
  165.   inc( object.count, 1 ); ! Creates an identical copy ! 
  166.   goto XSTOP;
  167.  
  168. :M2_LEAVE     ! Exit through the 'exit' door from anywhere...  
  169.   if world.type <> DUNGEON then
  170.     writeln( "This spell only work's in dungeons.." );
  171.     goto XSTOP;
  172.   endif;
  173.   enter( world.edgedoor );
  174.   writeln( "You leave this level of the dungeon.." );
  175.   goto XSTOP;
  176.  
  177. :M2_RESURRECT ! Revive a DEAD person                   
  178.   write( "Resurrect: " );
  179.   L3 = select( group );
  180.   if player.hp > 0 then
  181.     writeln( player.name, " is not dead!  The spell fails." );
  182.   else
  183.     writeln( player.name );
  184.     player.hp = 2;
  185.     writeln( player.name, " is alive, but weak.." );
  186.   endif;
  187.   goto XSTOP;
  188.  
  189. :M2_INFORM    ! Displays some text                     
  190.   loadhint;
  191.   writeln( "The wind seems to carry a random phrase to your ears.." );
  192.   writeln( s0 );
  193.   goto XSTOP;
  194.  
  195. :M2_LOCATE    ! Locate doors                           
  196.   for L5 = 0 to 15 do
  197.     if world.doorx(L5) > 0 and world.doory(L5) > 0 then
  198.       frame( world.doorx(L5), world.doory(L5), SYS_FRAME );
  199.     endif;
  200.   endfor;
  201.   goto XSTOP;
  202.  
  203. :M2_KILL      ! Kill 1 enemy during battle             
  204.   voice( "SPELL", 1000 );
  205.   writeln( npc.name, " killed. +", npc.hp, " exp." );
  206.   inc( player.exp, npc.hp );
  207.   npc.hp = 0;
  208.   npc.count = 0;
  209.   goto XSTOP;
  210.  
  211. :M2_DAMAGE    ! Causes damage to monsters              
  212.   voice( "SPELL", 1000 );
  213.   S0 = "hit";
  214.   foreach npc do
  215.     L7 = min( npc.hp, random(L6) );  ! How much damage to this one monster?
  216.     ! Note that I do not adjust damage according to the npc's AC !
  217.     if L7 > 0 then
  218.       frame(npc.x, npc.y, SYS_SPLAT);
  219.       wait(1);
  220.       frame(npc.x, npc.y, -1 );
  221.       write( npc.name );
  222.       if L7 < npc.hp then
  223.         write( " hit." );
  224.         dec( npc.hp, L7 );           ! Hit the monster..
  225.       else
  226.         write( " killed!" );
  227.         npc.hp = 0;
  228.         npc.count = 0;
  229.       endif;
  230.       writeln( " +", L7, " exp." );
  231.       inc(L9);                       ! Count of affected npcs
  232.       inc( L5, L7 );                 ! Accumulate experience..
  233.       if L5 > L8 goto DCSPEXIT;      ! Stop when total of L8 points used
  234.     endif;
  235.   endfor;  
  236.   goto DCSPEXIT;
  237.  
  238. :M2_CONFUSE   ! Makes monsters shoot at other monsters 
  239.   voice( "SPELL", 1000 );
  240.   S0 = "confused";
  241.   foreach npc do
  242.     L7 = min( npc.hp, random(L6) );  ! How much confusion to this one monster?
  243.     if L7 > 0 and npc.confused = 0 then
  244.       frame(npc.x, npc.y, SYS_SPLAT);
  245.       wait(1);
  246.       frame(npc.x, npc.y, -1 );
  247.       inc(L9);                       ! Count of affected npcs
  248.       npc.confused = L7;             ! Confuse for 'n' units
  249.       inc( L5, L7 );                 ! Accumulate experience..
  250.       if L5 > L8 goto DCSPEXIT;      ! Stop when total of L8 points used
  251.     endif;
  252.   endfor;  
  253.   goto DCSPEXIT;
  254.  
  255. :M2_SCARE     ! Scares monsters                        
  256.   voice( "SPELL", 1000 );
  257.   S0 = "scared";
  258.   foreach npc do
  259.     L7 = min( npc.hp, random(L6) );  ! How much 'fright' to this one monster?
  260.     if L7 > 0 and npc.scared = 0 then
  261.       frame(npc.x, npc.y, SYS_SPLAT);
  262.       wait(1);
  263.       frame(npc.x, npc.y, -1 );
  264.       inc(L9);
  265.       npc.scared = L7;               ! Frighten for 'n' units
  266.       inc( L5, L7 );                 ! Accumulate experience..
  267.       if L5 > L8 goto DCSPEXIT;      ! Stop when total of L8 points used
  268.     endif;
  269.   endfor;  
  270.   goto DCSPEXIT;
  271.  
  272. :M2_PARALYZE  ! Monster can't move                     
  273.   voice( "SPELL", 1000 );
  274.   S0 = "paralyzed";
  275.   foreach npc do
  276.     L7 = min( npc.hp, random(L6) );  ! How much paralysis to this one monster?
  277.     if L7 > 0 and npc.paralyzed = 0 then
  278.       frame(npc.x, npc.y, SYS_SPLAT);
  279.       wait(1);
  280.       frame(npc.x, npc.y, -1 );
  281.       inc(L9);
  282.       npc.paralyzed = L7;            ! Paralyze for 'n' units
  283.       inc( L5, L7 );                 ! Accumulate experience..
  284.       if L5 > L8 goto DCSPEXIT;      ! Stop when total of L8 points used
  285.     endif;
  286.   endfor;  
  287.   goto DCSPEXIT;
  288.  
  289. :M2_RECHARGE  ! Recharge an ITEM                       pwr = 25, rng=1
  290.   if object.type = RING or object.type = AMULET or object.type = STAFF then
  291.     inc( object.charges, random(player.level)+1 );
  292.     writeln( "The ", object.type, " now has ", object.charges, " charges." );
  293.   else
  294.     writeln( "The smell of rotten eggs fills the air.." );
  295.   endif;
  296.   goto XSTOP;
  297.  
  298. :M2_FLOAT     ! Remove an object's weight              pwr = 10, rng=1
  299.   if object.weight < 255 then
  300.     object.weight = object.weight / 2 + 1;
  301.     writeln( "The ", object.type, " is now much lighter.." );
  302.   else
  303.     writeln( "It's didn't work.  The ", object.type, " is too heavy." );
  304.   endif;
  305.   goto XSTOP;
  306.  
  307. :M2_ANALYZE   ! Discover object's properties           pwr = 10, rng=1
  308.   if npc.count then ! It's a character we cast this thing on..
  309.     writeln( npc.name, ", ", npc.class, ", Cnt:", npc.count, " L:", npc.level,
  310.              ", AC:", npc.ac, ", HP:", npc.hp );
  311.   else
  312.     gosub ODETAIL;
  313.   endif;
  314.     goto XSTOP;
  315.  
  316. :M2_ZOOM      ! View the world.. 
  317.   viewpcx( world );
  318.   if success then
  319.     pause;
  320.   endif;
  321.   paint( window );
  322.   goto XSTOP;
  323.  
  324.  
  325. !
  326. ! Award experience points (if any)
  327. !
  328. :DCSPEXIT
  329.   if L9 then
  330.     write( L9, " foes were ", S0 );
  331.     if L5 then  
  332.       writeln( " for a total of +", L5, " experience!" );
  333.       inc( player.exp, L5 );           ! Grant experience..
  334.     else
  335.       writeln( " With no effect" );
  336.     endif;
  337.   else
  338.     writeln( "No effect.." );
  339.   endif;
  340.   goto XSTOP;
  341.  
  342. !
  343. ! SUBROUTINE: X_TARGET
  344. !
  345. ! Selects a target to cast the spell on
  346. !
  347. :X_TARGET
  348.   write( s0, " what:" );
  349.   L3 = locate;               ! Identify an object or character to cast on !
  350.   if failure then
  351.     writeln( "nothing.." );
  352.     goto XSTOP;
  353.   endif;
  354.   if L3 > L2 then
  355.     writeln( "You must get closer.." );
  356.     goto XSTOP;
  357.   endif;
  358.   if npc.count then ! It's a character, not an object..
  359.     if npc.type = HOSTILE then
  360.       writeln( npc.name );  ! Monster's class is type of terrain mobility !
  361.     else
  362.       writeln( npc.class ); ! Human, elf, dwarf, etc..       !
  363.     endif;
  364.     if L0 = DESTROY  or L0 = DUPLICATE or
  365.        L0 = RECHARGE or L0 = FLOAT then
  366.       writeln( "This spell only work's on objects!" );
  367.       goto XSTOP;
  368.     endif;
  369.   else
  370.     writeln( object.type );  ! Food, weapon, ring, etc..      !
  371.   endif;
  372.   return;
  373.  
  374. !
  375. ! SUBROUTINE: ODETAIL
  376. !
  377. ! Display an object's detailed analysis
  378. !
  379. :ODETAIL
  380.   write( "Name: ", object.name );
  381.   write( ", Type: ", object.type );
  382.   if object.type = FOOD or object.type = POTION  then
  383.     if object.class then
  384.       write( ", Class: ", object.class );
  385.       if object.class <> CURE then
  386.         write( ", Units: ", object.units );
  387.       endif;
  388.     endif;
  389.   elsif object.type = WEAPON then
  390.     write( "Class: ", object.class, 
  391.            ", Hands: ", object.hands, 
  392.            ", Range: ", object.range, 
  393.            ", Damage: ", object.damage );
  394.     if object.ammoneeded then
  395.       write( ", Needs ammo type: ", object.ammo_type );
  396.     endif;
  397.   elsif object.type = AMMO then
  398.     write( "Ammo Type: ", object.ammotype );
  399.     if object.traptype then
  400.       write( ", Poisoned" );
  401.     endif;
  402.     if object.damage then
  403.       write( ", Extra Damage: ", object.damage );
  404.     endif;
  405.   elsif object.type = ARMOR or object.type = SHIELD then
  406.     write( "Armor Class: ", object.ac );
  407.     if object.cursed then
  408.       write( " Cursed!" );
  409.     endif;
  410.   elsif object.type = AMULET or object.type = RING or object.type = GEMS then
  411.     if object.class then
  412.       write( "Class: ", object.class );
  413.       write( ", Charges: ", object.charges );
  414.       if object.class <> CURE then
  415.         write( ", Units: ", object.units );
  416.         if object.permanent then
  417.           write( ", Permanent!" );
  418.         else
  419.           write( ", Temporary" );
  420.         endif;
  421.       endif;
  422.       if object.cursed then
  423.         write( ", Cursed!" );
  424.       endif;
  425.     endif;
  426.   elsif object.type = SCROLL then
  427.     write( "Class: ", object.class );
  428.   elsif object.type = STAFF then
  429.     write( "Class: ", object.class, ", Charges: ", object.charges );
  430.   elsif object.type = CHEST then
  431.     if object.locktype then
  432.       write( "Locked!" );
  433.       if object.traptype = 0 then
  434.         write( ", no traps" );
  435.       elsif object.traptype = 1 then
  436.         write( ", poison trap" );
  437.       else
  438.         write( ", bomb damage: ", object.traptype );
  439.       endif;
  440.     endif;
  441. ! elsif object.type = KEYS     then
  442. !   nothing special about it
  443. ! elsif object.type = BOOK     then
  444. !   nothing special about it
  445. ! elsif object.type = GOLDSACK then
  446. !   nothing special about it
  447. ! elsif object.type = TORCH    then
  448. !   nothing special about it
  449. ! elsif object.type = LANTERN  then
  450. !   nothing special about it
  451. ! elsif object.type = ROPE     then
  452. !   nothing special about it
  453. ! elsif object.type = HOOKS    then
  454. !   nothing special about it
  455. ! elsif object.type = MIRROR   then
  456. !   nothing special about it
  457. ! elsif object.type = SIGN     then
  458. !   nothing special about it
  459.   elsif object.type = VEHICLE then
  460.     write( "Class: ", object.class );
  461. ! else
  462. !   user defined type?
  463.   endif;
  464.   if object.weight > 1 and object.weight < 256 then
  465.     write( ", Weight: ", object.weight );
  466.   endif;
  467.   if object.count > 1 then
  468.     write( ", Count: ", object.count );
  469.   endif;
  470.   return;
  471.  
  472.